package com.onesports.intelligent.k12.polarlight.service.course;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.onesports.intelligent.k12.polarlight.domain.entity.course.SpellingClassDetails;
import com.onesports.intelligent.k12.polarlight.mapper.course.SpellingClassDetailsMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Wsy
 **/
@RequiredArgsConstructor
@Service
public class SpellingClassDetailService extends ServiceImpl<SpellingClassDetailsMapper, SpellingClassDetails> {


    public SpellingClassDetails selectByClassId(String classId) {
        return this.getOne(new LambdaQueryWrapper<SpellingClassDetails>().eq(SpellingClassDetails::getClassInfoId, classId));
    }

    public List<SpellingClassDetails> selectByClassIds(List<String> classIdList) {
        return this.list(new LambdaQueryWrapper<SpellingClassDetails>().in(SpellingClassDetails::getClassInfoId, classIdList));
    }

    /**
     * 获取当前机构拼班方式下拉
     * @return
     */
    public List<String> listBySpellType(){
        return list().stream().map(SpellingClassDetails::getSpellType).distinct().collect(Collectors.toList());
    }
}
